home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Trusted Irix /B 4.0.4
/
Trusted-Irix B-4.0.1.iso
/
dist
/
eoe1.idb
/
etc
/
shutdown.z
/
shutdown
Wrap
Text File
|
1992-04-03
|
2KB
|
128 lines
#! /bin/sh
#Tag 0x00000f00
#ident "$Revision: 1.14 $"
# Sequence performed to change the init stat of a machine.
# This procedure checks to see if you are permitted and allows an
# interactive shutdown. The actual change of state, killing of
# processes and such are performed by the new init state, say 0,
# and its /etc/rc0.
# Usage: shutdown [ -y ] [ -g<grace-period> ] [ -i<init-state> ]
#! chmod +x ${file}
# Check the user id.
if [ -x /usr/bin/id ]
then
eval `id | sed 's/[^a-z0-9=].*//'`
if [ "${uid:=0}" -ne 0 ]
then
echo "$0: Only root can run /etc/shutdown."
exit 2
fi
fi
grace=60
askconfirmation=yes
initstate=0
while [ $# -gt 0 ]
do
case $1 in
-g[0-9]* )
grace=`expr "$1" : '-g\(.*\)'`
;;
-i[Ss016] )
initstate=`expr "$1" : '-i\(.*\)'`
;;
-i[2345] )
initstate=`expr "$1" : '-i\(.*\)'`
echo "$0: Initstate $initstate is not for system shutdown"
exit 1
;;
-y )
askconfirmation=
;;
-* )
echo "Illegal flag argument '$1'"
exit 1
;;
* )
echo "Usage: $0 [ -y ] [ -g<grace> ] [ -i<initstate> ]"
exit 1
esac
shift
done
if [ -n "${askconfirmation}" -a -x /etc/ckbupscd ]
then
# Check to see if backups are scheduled at this time
BUPS=`/etc/ckbupscd`
if [ "$BUPS" != "" ]
then
echo "$BUPS"
echo "Do you wish to abort this shutdown and return to
command level to do these backups? [y, n] \c"
read YORN
if [ "$YORN" = "y" -o "$YORN" = "Y" ]
then
exit 1
fi
fi
fi
if [ -z "${TZ}" -a -r /etc/TIMEZONE ]
then
. /etc/TIMEZONE
fi
echo 'Shutdown started. \c'
date
sync
cd /
trap "exit 1" 1 2 15
a="`who | wc -l`"
if [ ${a} -gt 1 -a ${grace} -gt 0 ]
then
if [ -x /etc/wall ]
then
su adm -c /etc/wall<<-!
The system will be shut down in ${grace} seconds.
Please log off now.
!
fi
sleep ${grace}
fi
if [ -x /etc/wall ]
then
/etc/wall <<-!
THE SYSTEM IS BEING SHUT DOWN! Log off now.
!
fi
sleep ${grace}
if [ ${askconfirmation} ]
then
echo "Do you want to continue with the shutdown? (y or n): \c"
read b
else
b=y
fi
if [ "$b" != "y" ]
then
if [ -x /etc/wall ]
then
/etc/wall <<-\!
False Alarm: The system will not be brought down.
!
fi
echo 'Shut down aborted.'
exit 1
fi
/etc/init ${initstate}